package com.hefeng.wx.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hefeng.common.core.utils.EmptyUtils;
import com.hefeng.wx.domain.CustomerManualWorkOrder;
import com.hefeng.wx.domain.WxOrderDispositionResult;
import com.hefeng.wx.domain.WxOrderDistribution;
import com.hefeng.wx.domain.WxUserOrder;
import com.hefeng.wx.mapper.WxOrderDispositionResultMapper;
import com.hefeng.wx.mapper.WxUserOrderMapper;
import com.hefeng.wx.service.GasResultService;
import com.hefeng.wx.service.WxOrderDispositionResultService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class WxOrderDispositionResultServiceImpl extends ServiceImpl<WxOrderDispositionResultMapper, WxOrderDispositionResult> implements WxOrderDispositionResultService {


    @Autowired
    private WxOrderDispositionResultMapper wxOrderDispositionResultMapper;

    @Autowired
    private GasResultService gasResultService;

    @Override
    public Map<String, Object> queryById(WxOrderDispositionResult wxOrderDispositionResult) {
        //小程序获取工单详情

        Map<String, Object> dataMap = new HashMap<>();
        LambdaQueryWrapper<WxOrderDispositionResult> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(WxOrderDispositionResult::getWorkId, wxOrderDispositionResult.getWorkId());
        queryWrapper.eq(WxOrderDispositionResult::getDispositionStatus, 1);
        List<WxOrderDispositionResult> datalist =  wxOrderDispositionResultMapper.selectList(queryWrapper);
        dataMap.put("图片和视频", datalist);
        if (datalist.isEmpty()) {
            Map<String, Object> list = gasResultService.getPa(wxOrderDispositionResult.getWorkId());
             if (list.isEmpty()) {
                Map<String, Object> faillist = gasResultService.getPb(wxOrderDispositionResult.getWorkId());
                dataMap.put("已转单，未完成", faillist);
            } else {
                dataMap.put("已完成", list);
            }
        }
        return dataMap;
    }
}